﻿//-----------------------------------------------------------------------
// <copyright company="Microsoft Corporation">
//     Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Microsoft.DevDiv.Wpf.Samples
{
    public struct LiveSearchImageSearchOptions
    {
        public string Query { get; set; }

        public int Count { get; set; }

        public int Offset { get; set; }

        public static bool operator ==(LiveSearchImageSearchOptions leftOperand, LiveSearchImageSearchOptions rightOperand)
        {
            return leftOperand.Equals(rightOperand);
        }

        public static bool operator !=(LiveSearchImageSearchOptions leftOperand, LiveSearchImageSearchOptions rightOperand)
        {
            return !leftOperand.Equals(rightOperand);
        }

        public override int GetHashCode()
        {
            string query = this.Query;
            int queryHashCode = (query != null) ? query.GetHashCode() : NullHashCode;

            int hashCode = queryHashCode;
            hashCode = ((hashCode << 5) + hashCode) ^ this.Count;
            hashCode = ((hashCode << 5) + hashCode) ^ this.Offset;

            return hashCode;
        }

        public override bool Equals(object obj)
        {
            if (obj is LiveSearchImageSearchOptions)
            {
                return this.Equals((LiveSearchImageSearchOptions)obj);
            }
            else
            {
                return false;
            }
        }

        public bool Equals(LiveSearchImageSearchOptions options)
        {
            return
                this.Query.Equals(options.Query)
                && this.Offset == options.Offset
                && this.Count == options.Count;
        }

        private const int NullHashCode = 0x61E04917;
    }
}